<?php
class template_guest_detail extends theme
{
	
	protected function head()
	{
	?>
<link type="text/css" rel="stylesheet" href="templates/project/css/project.css">

<script type="text/javascript" language="javascript" src="templates/project/js/project.js"></script>
	<?php
	}

	protected function center()
	{
		$project = $this->get('project');
		$tickets = $this->get('tickets');
		
		$customer = bone::get_user($project->customer_id);
		$manager = bone::get_user($project->manager_id);
		?>
<div class="center-title">项目名: <?php echo $project->name; ?></div>
<div class="center-content">

<div class="step">
	<ul class="icons">
		<li class="node-on"></li>
		<li class="process-on"><div class="process-arrow"></div></li>
		<?php
		// 等待报价
		if($project->step<PROJECT_STEP_QUOTA)
			echo '<li class="node-over"></li>';
		else
			echo '<li class="node-on"></li>';
			
			
		// 等待付款
		if($project->step<PROJECT_STEP_QUOTA)
		{
			echo '<li class="process-off"><div class="process-arrow"></div></li>';
			echo '<li class="node-off"></li>';
		}
		else if($project->step<PROJECT_STEP_PAY)
		{
			echo '<li class="process-on"><div class="process-arrow"></div></li>';
			echo '<li class="node-over"></li>';
		}
		else
		{
			echo '<li class="process-on"><div class="process-arrow"></div></li>';
			echo '<li class="node-on"></li>';
		}
		
		// 等待开发
		if($project->step<PROJECT_STEP_PAY)
		{
			echo '<li class="process-off"><div class="process-arrow"></div></li>';
			echo '<li class="node-off"></li>';
		}
		else if($project->step==PROJECT_STEP_PAY)
		{
			echo '<li class="process-on"><div class="process-arrow"></div></li>';
			echo '<li class="node-over"></li>';
		}
		else
		{
			echo '<li class="process-on"><div class="process-arrow"></div></li>';
			echo '<li class="node-on"></li>';
		}
		
		// 等待测试
		if($project->step<PROJECT_STEP_DEVELOP)
		{
			echo '<li class="process-off"><div class="process-arrow"></div></li>';
			echo '<li class="node-off"></li>';
		}
		else if($project->step==PROJECT_STEP_DEVELOP)
		{
			echo '<li class="process-off"><div class="process-arrow"><div class="step-progress-bg-l" style="width:'.$project->develop_progress*0.85.'%;"><div class="step-progress-bg-r"></div></div></div></li>';
			echo '<li class="node-off"></li>';
		}
		else
		{
			echo '<li class="process-on"><div class="process-arrow"></div></li>';
			echo '<li class="node-on"></li>';
		}
		
		// 等待完成
		if($project->step<PROJECT_STEP_DEBUG)
		{
			echo '<li class="process-off"><div class="process-arrow"></div></li>';
			echo '<li class="node-off"></li>';
		}
		else if($project->step==PROJECT_STEP_DEBUG)
		{
			echo '<li class="process-off"><div class="process-arrow"><div class="step-progress-bg-l" style="width:'.$project->debug_progress*0.85.'%;"><div class="step-progress-bg-r"></div></div></div></li>';
			echo '<li class="node-off"></li>';
		}
		else
		{
			echo '<li class="process-on"><div class="process-arrow"></div></li>';
			echo '<li class="node-on"></li>';
		}
		
		?>
		</li><div class="clrl"></div>
	</ul>
	
	<ul class="names">
		<li class="on">创建项目</li>
		<?php
		
		if($project->step<PROJECT_STEP_QUOTA)
			echo '<li class="over">等待工程师报价...</li>';
		else
			echo '<li class="on">工程师已报价</li>';
			
		if($project->step<PROJECT_STEP_QUOTA)
			echo '<li class="off">客户付款50%</li>';
		else if($project->step<PROJECT_STEP_PAY)
			echo '<li class="over">等待客户付款...</li>';
		else
			echo '<li class="on">客户已付款</li>';
		
		
		if($project->step<PROJECT_STEP_PAY)
			echo '<li class="off">开发</li>';
		else if($project->step==PROJECT_STEP_PAY)
			echo '<li class="over">等待程序员开工...</li>';
		else if($project->step==PROJECT_STEP_DEVELOP)
			echo '<li class="on">开发中...</li>';
		else
			echo '<li class="on">开发完成</li>';
			

		if($project->step<PROJECT_STEP_DEBUG)
			echo '<li class="off">调试</li>';
		else if($project->step==PROJECT_STEP_DEBUG)
			echo '<li class="on">调试中...</li>';
		else
			echo '<li class="on">调试完成</li>';


		if($project->step<PROJECT_STEP_COMPLETE)
			echo '<li class="off">完工,付余款</li>';
		else
			echo '<li class="on">已完工</li>';
		?>
	</ul><div class="clrl"></div>
</div>

<table width="90%" align="center">
<tr><td width="20%">客户: </td><td width="25%"><?php echo $customer->name; ?></td><td width="20%">总任务数: </td><td width="35%"><?php echo $project->ticket_count; ?></td></tr>
<tr><td>项目负责人: </td><td>
<a href="<?php echo url('./?controller=team&task=user_detail&user_id='.$project->manager_id); ?>" title="<?php echo $manager->name; ?>">
<?php echo $manager->name; ?>
</a></td><td>已完成的任务数: </td><td><?php echo $project->completed_ticket_count; ?></td></tr>
<tr><td>创建时间: </td><td><?php echo date('Y-m-d',$project->create_time); ?></td><td>总体开发进度: </td><td>
	<div class="progress"><div class="bg"><div class="bar" style="width:<?php echo $project->progress<5?5:$project->progress;?>px;"></div></div></div>
</td></tr>
<tr><td>预计验收时间: </td><td><?php echo date('Y-m-d',$project->estimate_time); ?></td></tr>


<?php if($project->complete_time){ ?>
<tr><td>结束时间: </td><td><?php echo date('Y-m-d',$project->complete_time); ?></td></tr>
<?php } ?>

</table>

</div>



<div class="center-title">任务列表</div>
<div class="center-content">

<div class="tickets">
<table width="98%" align="center">
<thead>
<tr><th>ID</th><th align="left">标题</th><th>状态</th><th></th></tr>
<thead>

<?php
if(count($tickets)>0)
{
	echo '<tbody>';
	foreach($tickets as $ticket)
	{
	?>
	<tr>
	<td align="center"><?php echo $ticket->id; ?></td>
	<td><a href=""><?php echo $ticket->title; ?></a></td>
	<td align="center"><?php echo $ticket->step; ?></td>
	<td align="center"></td>
	</tr>
	<?php
	}
	echo '</tbody>';
}
else
{
?>

<tfoot>
<tr><td colspan="4" align="center">暂无记录</td></tr>
</tfoot>
<?php
}
?>
</table>
</div>

</div>
		<?php
	}		
		

}
?>